/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import com.googlecode.charts4j.AxisLabelsFactory;
import com.googlecode.charts4j.BarChart;
import com.googlecode.charts4j.BarChartPlot;
import com.googlecode.charts4j.Color;
import com.googlecode.charts4j.Data;
import com.googlecode.charts4j.Fills;
import com.googlecode.charts4j.GCharts;
import com.googlecode.charts4j.LegendPosition;
import com.googlecode.charts4j.LinearGradientFill;
import com.googlecode.charts4j.PieChart;
import com.googlecode.charts4j.Plots;
import com.googlecode.charts4j.*;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import modelo.Tabla;
import modelo.Tablespace;
import modelo.Usuario;
import modelo.persistencia.BIN;
import modelo.regresion.RegresionLineal;
import modelo.regresion.TableSpaceRegresion;

/**
 *
 * @author Andrés
 */
public final class VistaPrincipalTablespaces extends javax.swing.JFrame {

    /**
     * Creates new form VistaPrincipal
     */
    private List<Color> colors;
    JFrame frame = this;
    private DefaultTableModel defaultTableModel;

    public VistaPrincipalTablespaces() {
        initComponents();
        setVisible(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        this.setResizable(false);
        inicializarVariables();
        iniciarLogo();
        iniciarColores();

        BIN bin = new BIN();
        Usuario usuarioBD = (Usuario) bin.leer();
        this.correoAdmin.setText(usuarioBD.getEmail());
    }

    public final void inicializarVariables() {
        this.defaultTableModel = new DefaultTableModel();
        defaultTableModel = (DefaultTableModel) tablaPronostico.getModel();

    }

    public final void iniciarLogo() {
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("./image/logo.png")));
    }

    public void agregarListenerItemCerrar(ActionListener actionListener) {
        this.itemCerrar.addActionListener(actionListener);
    }

    public void agregarListenerItemAcerdaDe(ActionListener actionListener) {
        this.itemAcercaDe.addActionListener(actionListener);
    }

    public void agregarListenerItemPreferencias(ActionListener actionListener) {
        this.itemConfig.addActionListener(actionListener);
    }
        public void agregarListenerItemCambiarMonitor(ActionListener actionListener) {
        this.itemMonitores.addActionListener(actionListener);
    }

    public void agregarListenerBotonDetalles(ActionListener actionListener) {
        this.botonDetalles.addActionListener(actionListener);
    }

    public void agregarOpcionesTablespaces(ArrayList<Tablespace> tablespaces) {
        DefaultListModel model = new DefaultListModel();
        model.clear();
        if (defaultTableModel.getRowCount() > 0) {
            for (int i = defaultTableModel.getRowCount() - 1; i > -1; i--) {
                defaultTableModel.removeRow(i);
            }
        }
        model.addElement("Todos");
        for (Tablespace tb : tablespaces) {
            model.addElement(tb.getNombre());
        }
        listaTablespaces.setModel(model);
        scrollTablespaces.setViewportView(listaTablespaces);
    }

    public void agregarListenerListaTablespaces(ListSelectionListener listener) {
        listaTablespaces.addListSelectionListener(listener);
    }

    public String obtenerSeleccionTableSpace() {
        return listaTablespaces.getSelectedValue().toString();
    }

    public void generarGrafico(ArrayList<Tablespace> tablespaces, String nombre) throws MalformedURLException {
        if (nombre.equals("Todos")) {
            int tam = 0;
            for (Tablespace tb : tablespaces) {
                tam += tb.getTamanoTotal(tb.cantidadDias() - 1);
            }
            List<Slice> sli = new ArrayList<>();
            List<BarChartPlot> ps = new ArrayList<>();
            int prctj_usado;
            Color color;
            for (Tablespace tb : tablespaces) {
                color = colors.get(0 + (int) (Math.random() * colors.size()));
                prctj_usado = (100 * tb.getTamanoTotal(tb.cantidadDias() - 1)) / tam;
                sli.add(Slice.newSlice(prctj_usado, color, tb.getNombre() + " " + String.valueOf(prctj_usado) + "%"/*, String.valueOf(prctj_usado)*/));
                ps.add(Plots.newBarChartPlot(Data.newData(prctj_usado), color, tb.getNombre()));
            }
            generarGraficoResumen(ps);
            PieChart chart = GCharts.newPieChart(sli);
            chart.setTitle("Proporción de Tablespaces ", Color.BLACK, 16);
            chart.setTransparency(70);
            chart.setThreeD(true);
            chart.setSize(410, 200);
            chart.setMargins(0, 40, 40, 50);
            //chart.setLegendMargins(50, 50);
            //chart.setLegendPosition(LegendPosition.RIGHT);
            String url = chart.toURLString();
            URL img = new URL(url);
            ImageIcon image = new ImageIcon(img);
            this.graficoTablespaces.setIcon(image);
        } else {
            for (Tablespace tb : tablespaces) {
                Slice s1;
                Slice s2;
                if (tb.getNombre().equals(nombre)) {
                    s1 = Slice.newSlice((int) tb.getPrctjLibre(tb.cantidadDias() - 1), Color.GRAY, "Libre",
                            String.valueOf(tb.getPrctjLibre(tb.cantidadDias() - 1)) + " % " + "Libre");
                    s2 = Slice.newSlice(100 - (int) tb.getPrctjLibre(tb.cantidadDias() - 1), Color.RED, "Usado",
                            String.valueOf(100 - (int) tb.getPrctjLibre(tb.cantidadDias() - 1)) + " % " + "Usado");
                    PieChart chart = GCharts.newPieChart(s1, s2);
                    chart.setTitle("Espacio utilizado en " + tb.getNombre(), Color.BLACK, 16);
                    chart.setTransparency(70);
                    chart.setThreeD(true);
                    chart.setSize(430, 200);
                    chart.setMargins(30, 30, 30, 30);
                    chart.setLegendMargins(50, 50);
                    chart.setLegendPosition(LegendPosition.BOTTOM_VERTICAL);
                    String url = chart.toURLString();
                    URL img = new URL(url);
                    ImageIcon image = new ImageIcon(img);
                    this.graficoTablespaces.setIcon(image);
                }
            }
        }
    }

    public void setBase(String tipo) {
        this.baseDatos.setText(tipo);
    }

    public void setDias(int dias) {
        this.diasMonitor.setText(String.valueOf(dias));
    }

    public void setCantTablespaces(int cant) {
        this.cantTablespaces.setText(String.valueOf(cant));
    }

    public void setCorreo(String correo) {
        this.correoAdmin.setText(correo);
    }

    public void setEstado(int state) {
        switch (state) {
            case 1:
                this.estadoActual.setText("Estable");
                this.estadoActual.setForeground(new java.awt.Color(0, 110, 0));
                break;
            case 2:
                this.estadoActual.setText("Regular");
                this.estadoActual.setForeground(java.awt.Color.BLACK);
                break;
            case 3:
                this.estadoActual.setText("Crítico");
                this.estadoActual.setForeground(java.awt.Color.RED);
                break;
        }
    }

    public void generarGraficoResumen(List<BarChartPlot> ps) throws MalformedURLException {
        BarChart chart = GCharts.newBarChart(ps);
        // Defining axis info and styles

        chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels("BD"));
        chart.addYAxisLabels(AxisLabelsFactory.newNumericRangeAxisLabels(0, 100));
        chart.setSize(350, 200);
        chart.setBarWidth(20);
        chart.setSpaceWithinGroupsOfBars(10);
        chart.setDataStacked(true);
        chart.setTitle("Tablespaces", Color.BLACK, 16);
        chart.setGrid(50, 5, 2, 1);
        chart.setMargins(80, 80, 4, 4);
        LinearGradientFill fill = Fills.newLinearGradientFill(0, Color.LAVENDER, 100);
        fill.addColorAndOffset(Color.WHITE, 0);
        chart.setAreaFill(fill);
        String url = chart.toURLString();
        URL img = new URL(url);
        ImageIcon image = new ImageIcon(img);
        this.graficoResumen.setIcon(image);
    }

    public void pintarHistorico(List<Tablespace> tablespaces) throws MalformedURLException {

        int cantidadDias = tablespaces.get(0).cantidadDias();
        float dato;
        float libre;
        float total;
        ArrayList<String> dias = new ArrayList<>();
        double[] usadoBase = new double[cantidadDias];
        total = tablespaces.size();
        for (int i = 0; i < cantidadDias; i++) {
            libre = 0;
            dato = 0;
            dias.add(tablespaces.get(0).getDiaTablespace(i).getFecha());
            for (Tablespace tb : tablespaces) {
                libre += tb.getDiaTablespace(i).getPctj_libre();
            }
            dato = libre * 100;
            dato /= 100 * tablespaces.size();
            total = 100 - dato;
            usadoBase[i] = total;
        }
        Line line1 = Plots.newLine(Data.newData(usadoBase), Color.newColor("CA3D05"));
        line1.setLineStyle(LineStyle.newLineStyle(3, 1, 0));
        line1.addShapeMarkers(Shape.DIAMOND, Color.newColor("CA3D05"), 12);
        line1.addShapeMarkers(Shape.DIAMOND, Color.WHITE, 8);


        // Defining chart.
        LineChart chart = GCharts.newLineChart(line1);
        chart.setSize(600, 450);
        chart.setTitle("Crecimiento de Espacio|Utilizado en la base de datos", Color.WHITE, 14);
        chart.addHorizontalRangeMarker(70, 100, Color.newColor(Color.RED, 30));

        chart.setGrid(25, 25, 3, 2);

        // Defining axis info and styles
        AxisStyle axisStyle = AxisStyle.newAxisStyle(Color.WHITE, 12, AxisTextAlignment.CENTER);


        AxisLabels yAxis = AxisLabelsFactory.newAxisLabels("", "25", "50", "75", "100");


        yAxis.setAxisStyle(axisStyle);;


        AxisLabels labels = AxisLabelsFactory.newAxisLabels(dias);
        // Adding axis info to chart.
        chart.addXAxisLabels(labels);
        chart.addYAxisLabels(yAxis);

        // Defining background and chart fills.
        chart.setBackgroundFill(Fills.newSolidFill(Color.newColor("1F1D1D")));
        LinearGradientFill fill = Fills.newLinearGradientFill(0, Color.newColor("363433"), 100);
        fill.addColorAndOffset(Color.newColor("2E2B2A"), 0);
        chart.setAreaFill(fill);
        chart.setSize(620, 200);
        String url = chart.toURLString();
        URL img = new URL(url);
        ImageIcon image = new ImageIcon(img);
        this.graficoHistorico.setIcon(image);

    }

    public void mostrarPronostico(ArrayList<String> tablespace, ArrayList<String> pronosticos) {
        DefaultListModel model = new DefaultListModel();
        model.clear();
        if (defaultTableModel.getRowCount() > 0) {
            for (int i = defaultTableModel.getRowCount() - 1; i > -1; i--) {
                defaultTableModel.removeRow(i);
            }
        }
        for (int i = 0; i < tablespace.size(); i++) {
            model.addElement(tablespace.get(i));
            defaultTableModel.addRow(new Object[]{tablespace.get(i), formatoPronostico(pronosticos.get(i))});
        }
        tablaPronostico.repaint();
        //panelTablas.setViewportView(listaTablas);
        this.repaint();
    }

    public String formatoPronostico(String pron) {
        String pronFormato = new String();
        String tipo = new String();
        Float t = Float.parseFloat(pron);
        if (t > 365) {
            t /= 365;
            tipo = " Años ";
        } else {
            if (t > 30) {
                t /= 30;
                tipo = " Meses ";
            } else {
                tipo = " Días ";
            }
        }
        double roundOff = Math.round(t * 100.0) / 100.0;
        pronFormato = roundOff + " " + tipo;
        return pronFormato;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem1 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        graficoResumen = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        graficoTablespaces = new javax.swing.JLabel();
        scrollTablespaces = new javax.swing.JScrollPane();
        listaTablespaces = new javax.swing.JList();
        botonDetalles = new javax.swing.JButton();
        panelHistorico = new javax.swing.JScrollPane();
        graficoHistorico = new javax.swing.JLabel();
        scrollPronostico = new javax.swing.JScrollPane();
        tablaPronostico = new javax.swing.JTable();
        panelInfo = new javax.swing.JPanel();
        etiquetaEstado = new javax.swing.JLabel();
        estadoActual = new javax.swing.JLabel();
        etiquetaBase = new javax.swing.JLabel();
        etiquetaCorreo = new javax.swing.JLabel();
        baseDatos = new javax.swing.JLabel();
        correoAdmin = new javax.swing.JLabel();
        etiquetaDias = new javax.swing.JLabel();
        diasMonitor = new javax.swing.JLabel();
        etiquetaTablespaces = new javax.swing.JLabel();
        cantTablespaces = new javax.swing.JLabel();
        barraMenu = new javax.swing.JMenuBar();
        menuArchivo = new javax.swing.JMenu();
        apariencia = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        itemConfig = new javax.swing.JMenuItem();
        itemMonitores = new javax.swing.JMenuItem();
        itemCerrar = new javax.swing.JMenuItem();
        menuAyuda = new javax.swing.JMenu();
        itemAcercaDe = new javax.swing.JMenuItem();

        jMenuItem1.setText("jMenuItem1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Monitor Administración de Bases de Datos");
        setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Consumo por Tablespace", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(graficoResumen, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(graficoResumen, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Graficos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black));

        listaTablespaces.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listaTablespaces.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        scrollTablespaces.setViewportView(listaTablespaces);

        botonDetalles.setText("Detalles");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(botonDetalles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(scrollTablespaces, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
                .addContainerGap(376, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                    .addContainerGap(116, Short.MAX_VALUE)
                    .addComponent(graficoTablespaces, javax.swing.GroupLayout.PREFERRED_SIZE, 363, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(scrollTablespaces)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(botonDetalles, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(graficoTablespaces, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addContainerGap()))
        );

        panelHistorico.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Historico Base de Datos"));
        panelHistorico.setViewportView(graficoHistorico);

        tablaPronostico.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Tablespace", "Pronostico"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        scrollPronostico.setViewportView(tablaPronostico);

        etiquetaEstado.setText("Estado:");

        estadoActual.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        estadoActual.setText("...");

        etiquetaBase.setText("Base de Datos: ");

        etiquetaCorreo.setText("Correo Administrador:");

        baseDatos.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        baseDatos.setText("...");

        correoAdmin.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        correoAdmin.setText("...");

        etiquetaDias.setText("Dias Monitoreados:");

        diasMonitor.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        diasMonitor.setText("...");

        etiquetaTablespaces.setText("Cantidad Tablespaces");

        cantTablespaces.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        cantTablespaces.setText("...");

        javax.swing.GroupLayout panelInfoLayout = new javax.swing.GroupLayout(panelInfo);
        panelInfo.setLayout(panelInfoLayout);
        panelInfoLayout.setHorizontalGroup(
            panelInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(estadoActual, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cantTablespaces, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(diasMonitor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(baseDatos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(correoAdmin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelInfoLayout.createSequentialGroup()
                        .addGroup(panelInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(etiquetaBase)
                            .addComponent(etiquetaCorreo)
                            .addComponent(etiquetaDias)
                            .addComponent(etiquetaTablespaces)
                            .addComponent(etiquetaEstado))
                        .addGap(0, 20, Short.MAX_VALUE)))
                .addContainerGap())
        );
        panelInfoLayout.setVerticalGroup(
            panelInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(etiquetaBase)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(baseDatos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(etiquetaCorreo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(correoAdmin)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(etiquetaDias)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(diasMonitor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(etiquetaTablespaces)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cantTablespaces)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(etiquetaEstado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(estadoActual)
                .addContainerGap())
        );

        menuArchivo.setText("Archivo");

        apariencia.setText("Apariencia");

        jMenuItem2.setText("Clasico");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        apariencia.add(jMenuItem2);

        jMenuItem3.setText("Aluminium");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        apariencia.add(jMenuItem3);

        menuArchivo.add(apariencia);

        itemConfig.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        itemConfig.setText("Preferencias");
        menuArchivo.add(itemConfig);

        itemMonitores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK));
        itemMonitores.setText("Cambiar Monitor");
        menuArchivo.add(itemMonitores);

        itemCerrar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        itemCerrar.setText("Cerrar");
        menuArchivo.add(itemCerrar);

        barraMenu.add(menuArchivo);

        menuAyuda.setText("Ayuda");

        itemAcercaDe.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
        itemAcercaDe.setText("Acerca de");
        menuAyuda.add(itemAcercaDe);

        barraMenu.add(menuAyuda);

        setJMenuBar(barraMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(scrollPronostico, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(panelInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(panelHistorico)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(scrollPronostico, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(panelInfo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(panelHistorico, javax.swing.GroupLayout.PREFERRED_SIZE, 243, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(33, 33, 33))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed


        try {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            SwingUtilities.updateComponentTreeUI(frame);
            frame.pack();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error. El estilo no corresponde a este sistema operativo");
        }

    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed

        try {
            UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
            SwingUtilities.updateComponentTreeUI(frame);
            frame.pack();

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error. El estilo no corresponde a este sistema operativo");
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VistaPrincipalTablespaces.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VistaPrincipalTablespaces.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VistaPrincipalTablespaces.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VistaPrincipalTablespaces.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VistaPrincipalTablespaces().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu apariencia;
    private javax.swing.JMenuBar barraMenu;
    private javax.swing.JLabel baseDatos;
    private javax.swing.JButton botonDetalles;
    private javax.swing.JLabel cantTablespaces;
    private javax.swing.JLabel correoAdmin;
    private javax.swing.JLabel diasMonitor;
    private javax.swing.JLabel estadoActual;
    private javax.swing.JLabel etiquetaBase;
    private javax.swing.JLabel etiquetaCorreo;
    private javax.swing.JLabel etiquetaDias;
    private javax.swing.JLabel etiquetaEstado;
    private javax.swing.JLabel etiquetaTablespaces;
    private javax.swing.JLabel graficoHistorico;
    private javax.swing.JLabel graficoResumen;
    private javax.swing.JLabel graficoTablespaces;
    private javax.swing.JMenuItem itemAcercaDe;
    private javax.swing.JMenuItem itemCerrar;
    private javax.swing.JMenuItem itemConfig;
    private javax.swing.JMenuItem itemMonitores;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JList listaTablespaces;
    private javax.swing.JMenu menuArchivo;
    private javax.swing.JMenu menuAyuda;
    private javax.swing.JScrollPane panelHistorico;
    private javax.swing.JPanel panelInfo;
    private javax.swing.JScrollPane scrollPronostico;
    private javax.swing.JScrollPane scrollTablespaces;
    private javax.swing.JTable tablaPronostico;
    // End of variables declaration//GEN-END:variables

    public void iniciarColores() {
        colors = new ArrayList<>();
        colors.add(Color.AQUA);
        colors.add(Color.BEIGE);
        colors.add(Color.BLACK);
        colors.add(Color.BLUE);
        colors.add(Color.BROWN);
        colors.add(Color.BURLYWOOD);
        colors.add(Color.CORAL);
        colors.add(Color.CRIMSON);
        colors.add(Color.CYAN);
        colors.add(Color.DARKBLUE);
        colors.add(Color.DARKCYAN);
        colors.add(Color.DARKGRAY);
        colors.add(Color.DARKGREEN);
        colors.add(Color.DARKMAGENTA);
        colors.add(Color.DARKOLIVEGREEN);
        colors.add(Color.DARKORANGE);
        colors.add(Color.DARKORCHID);
        colors.add(Color.DARKRED);
        colors.add(Color.DARKSALMON);
        colors.add(Color.DARKSEAGREEN);
        colors.add(Color.DARKSLATEBLUE);
        colors.add(Color.DARKSLATEGRAY);
        colors.add(Color.DARKTURQUOISE);
        colors.add(Color.DEEPSKYBLUE);
        colors.add(Color.DIMGRAY);
        colors.add(Color.DODGERBLUE);
        colors.add(Color.FIREBRICK);
        colors.add(Color.FLORALWHITE);
        colors.add(Color.FORESTGREEN);
        colors.add(Color.GOLD);
        colors.add(Color.GREEN);
        colors.add(Color.GREENYELLOW);
        colors.add(Color.HONEYDEW);
        colors.add(Color.INDIANRED);
        colors.add(Color.INDIGO);
        colors.add(Color.IVORY);
        colors.add(Color.KHAKI);
        colors.add(Color.LAVENDER);
        colors.add(Color.LAWNGREEN);
        colors.add(Color.LEMONCHIFFON);
        colors.add(Color.LIGHTCORAL);
        colors.add(Color.LIGHTCYAN);
        colors.add(Color.LIGHTGREEN);
        colors.add(Color.LIGHTGREY);
        colors.add(Color.LIGHTPINK);
        colors.add(Color.LIGHTSALMON);
        colors.add(Color.LIGHTSEAGREEN);
        colors.add(Color.LIGHTSKYBLUE);
        colors.add(Color.LIGHTSLATEGRAY);
        colors.add(Color.LIGHTSTEELBLUE);
        colors.add(Color.LIGHTYELLOW);
        colors.add(Color.LIME);
        colors.add(Color.LIMEGREEN);
        colors.add(Color.LINEN);
        colors.add(Color.MAGENTA);
        colors.add(Color.MAROON);
        colors.add(Color.MEDIUMAQUAMARINE);
        colors.add(Color.MEDIUMBLUE);
        colors.add(Color.MEDIUMORCHID);
        colors.add(Color.MEDIUMPURPLE);
        colors.add(Color.MEDIUMSEAGREEN);
        colors.add(Color.MEDIUMSLATEBLUE);
        colors.add(Color.MEDIUMSPRINGGREEN);
        colors.add(Color.MEDIUMTURQUOISE);
        colors.add(Color.MEDIUMVIOLETRED);
        colors.add(Color.MIDNIGHTBLUE);
        colors.add(Color.MINTCREAM);
        colors.add(Color.MISTYROSE);
        colors.add(Color.MOCCASIN);
        colors.add(Color.NAVAJOWHITE);
        colors.add(Color.NAVY);
        colors.add(Color.OLDLACE);
        colors.add(Color.OLIVE);
        colors.add(Color.OLIVEDRAB);
        colors.add(Color.ORANGE);
        colors.add(Color.ORANGERED);
        colors.add(Color.ORCHID);
        colors.add(Color.PALEGOLDENROD);
        colors.add(Color.PALEGREEN);
        colors.add(Color.PALETURQUOISE);
        colors.add(Color.PALEVIOLETRED);
        colors.add(Color.PAPAYAWHIP);
        colors.add(Color.PEACHPUFF);
        colors.add(Color.PERU);
        colors.add(Color.PINK);
        colors.add(Color.PLUM);
        colors.add(Color.POWDERBLUE);
        colors.add(Color.PURPLE);
        colors.add(Color.RED);
        colors.add(Color.ROSYBROWN);
        colors.add(Color.ROYALBLUE);
        colors.add(Color.SADDLEBROWN);
        colors.add(Color.SALMON);
        colors.add(Color.SANDYBROWN);
        colors.add(Color.SEAGREEN);
        colors.add(Color.SEASHELL);
        colors.add(Color.SIENNA);
        colors.add(Color.SILVER);
        colors.add(Color.SKYBLUE);
        colors.add(Color.SLATEBLUE);
        colors.add(Color.SLATEGRAY);
        colors.add(Color.SNOW);
        colors.add(Color.SPRINGGREEN);
        colors.add(Color.STEELBLUE);
        colors.add(Color.TAN);
        colors.add(Color.TEAL);
        colors.add(Color.THISTLE);
        colors.add(Color.TOMATO);
        colors.add(Color.TURQUOISE);
        colors.add(Color.VIOLET);
        colors.add(Color.WHEAT);
        colors.add(Color.WHITE);
        colors.add(Color.WHITESMOKE);
        colors.add(Color.YELLOW);
        colors.add(Color.YELLOWGREEN);
    }
}
